# 文件名: social_media_monitor.spec
# -*- mode: python ; coding: utf-8 -*-

import os
from PyInstaller.utils.hooks import collect_data_files

block_cipher = None

# 获取项目根目录
current_dir = os.path.dirname(os.path.abspath('__file__'))

# 定义需要包含的数据文件
datas = [
    # 模板文件
    ('app/templates/*.html', 'app/templates'),
    # 静态文件
    ('app/static', 'app/static'),
    # 如果有.env文件
    ('.env', '.'),
]

# 收集隐藏导入
hiddenimports = [
    'app.models.database',
    'app.services.monitor_service',
    'app.routes.api',
    'app.routes.pages',
    'app.routes.websocket',
    'dotenv',
    'sqlalchemy.sql.default_comparator',
    'sqlalchemy.ext.baked',
    'pystray',  # 如果使用系统托盘
    'PIL',      # 系统托盘需要
]

a = Analysis(
    ['direct_run.py'],
    pathex=[current_dir],
    binaries=[],
    datas=datas,
    hiddenimports=hiddenimports,
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    win_no_prefer_redirects=False,
    win_private_assemblies=False,
    cipher=block_cipher,
    noarchive=False,
)

pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.zipfiles,
    a.datas,
    [],
    name='社交媒体监控-Flying-1.0.5',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=False,  # 显示控制台窗口，方便调试
    disable_windowed_traceback=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
    icon=os.path.join(current_dir, 'app', 'icons', 'social_media_monitor.ico')
)